﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControl_memberChangePassword : System.Web.UI.UserControl
{
    UsersController userColtrol;

    List<Users> userInfo = new List<Users>();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["memberName"] == null)
        {
            Response.Redirect("member.aspx");
        }
        userColtrol = new UsersController();
        userInfo = userColtrol.checkUserExist(Session["memberName"].ToString());
        txtUsername.Text = userInfo[0].Username;        
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        int userId = userInfo[0].User_id;
        string Username = txtUsername.Text;
        string Password = txtNewPassword.Text;
        int check = userColtrol.ChangPass(userId, Username, Password);
        if (check > 0)
        {
            Response.Redirect("dien-thoai");
        }
        else {
            Response.Redirect("phu-kien");
        }
    }
}